/*
编写 : Hexh
时间 : 2012-6-13 16:02:26
*/
using System;
using System.Collections;
using System.Text;
using HMIS.FrameWork.DomainBase;
using HMIS.Infrastructure.Core.Authority;
using HMIS.Infrastructure.Core.Entities;
using HMIS.FrameWork;

namespace FsCarInfo.Core.Entity
{
	/// <summary>
	///	the entity of FsCartransfer
	/// </summary>
	public  class FsCartransfer : InputItem
	{

		#region Public Properties
			
		/// <summary>
		/// 调拨单类型
		/// </summary>
		public virtual string TransferType { get; set; }

		/// <summary>
		/// 经办人ID
		/// </summary>
		public virtual string OperUserId { get; set; }

		/// <summary>
		/// 经办人
		/// </summary>
		public virtual HospUser OperUser { get; set; }

		/// <summary>
		/// 调出仓库ID
		/// </summary>
		public virtual string OutDeptId { get; set; }

		/// <summary>
		/// 调出仓库
		/// </summary>
		public virtual Department OutDept { get; set; }

		/// <summary>
		/// 调出仓管ID
		/// </summary>
		public virtual string OutDpuserId { get; set; }

		/// <summary>
		/// 调出仓管
		/// </summary>
		public virtual HospUser OutDpuser { get; set; }

		/// <summary>
		/// 调入仓库ID
		/// </summary>
		public virtual string InDeptId { get; set; }

		/// <summary>
		/// 调入仓库
		/// </summary>
		public virtual Department InDept { get; set; }

		/// <summary>
		/// 调入仓管ID
		/// </summary>
		public virtual string InDpuserId { get; set; }

		/// <summary>
		/// 调入仓管ID
		/// </summary>
		public virtual HospUser InDpuser { get; set; }

		/// <summary>
		/// 预计出发
		/// </summary>
		public virtual DateTime ExpOutTime { get; set; }

		/// <summary>
		/// 预计到达
		/// </summary>
		public virtual DateTime ExpArvTime { get; set; }

		/// <summary>
		/// 实际出发
		/// </summary>
		public virtual DateTime? ActOutTime { get; set; }

		/// <summary>
		/// 实际到达
		/// </summary>
		public virtual DateTime? ActArvTime { get; set; }

		/// <summary>
		/// 事由
		/// </summary>
		public virtual string Reason { get; set; }

		/// <summary>
		/// 状态
		/// </summary>
		public virtual FsCartransferState State { get; set; }

		/// <summary>
		/// 提醒短信发送时间
		/// </summary>
		public virtual DateTime? SmsTime { get; set; }

		/// <summary>
		/// 调拨车辆清单
		/// </summary>
		public virtual Iesi.Collections.Generic.ISet<FsCartransferDetail> Cars { get; set; }

						
		#endregion 

		#region Public Method

		/// <summary>
		/// 生成短信信息
		/// </summary>
		/// <returns></returns>
		public virtual string ToSmsString()
		{
			string smsStr = "[" + this.TransferType + "]\n经办:" + this.OperUser.Name + "," + this.OperUser.Mobitl + "\n事由:" + this.Reason
				+ "\n出发:" + this.ExpOutTime;
			if (this.TransferType == "") // "商品车外派"
				smsStr = smsStr + "\n返回:" + this.ExpArvTime + "\n调出:" + this.OutDept.Name + "\n调入:" + this.InDept.Name;
			else
				smsStr = smsStr + "\n到达:" + this.ExpArvTime + "\n展场:" + this.OutDept.Name;

			//车辆清单信息
			string carList = "\n[车辆:" + this.Cars.Count + "]";
			int index = 1;
			foreach (FsCartransferDetail car in this.Cars)
			{
				carList = carList + "\n" + index.ToString() + "." + car.Car.ToSmsString();
				index++;
			}
			return smsStr + carList;
		}

		#endregion

	}

	/// <summary>
	/// 调派状态
	/// </summary>
	public enum FsCartransferState
	{
		/// <summary>
		/// 待提交
		/// </summary>
		[EnumDescription("待提交")]
		Editing = 0,

		/// <summary>
		/// 待审批
		/// </summary>
		[EnumDescription("待审批")]
		Appling = 1,

		/// <summary>
		/// 否决
		/// </summary>
		[EnumDescription("否决")]
		Refused = 9,

		/// <summary>
		/// 已审批
		/// </summary>
		[EnumDescription("已审批")]
		Agreed = 2,

		/// <summary>
		/// 已出发
		/// </summary>
		[EnumDescription("已出发")]
		Processing = 3,

		/// <summary>
		/// 已接收
		/// </summary>
		[EnumDescription("已接收")]
		Returned = 4,

		/// <summary>
		/// 已接收
		/// </summary>
		[EnumDescription("已入库")]
		Stored = 5
	}
}
